package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.business.service.IRefundApprovalService;
import com.ruoyi.common.core.domain.entity.RefundApproval;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 退款审批记录Controller
 *
 * @author ruoyi
 * @date 2024-06-07
 */
@RestController
@RequestMapping("/business/approval")
public class RefundApprovalController extends BaseController
{
    @Autowired
    private IRefundApprovalService refundApprovalService;

    /**
     * 查询退款审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:approval:list')")
    @GetMapping("/list")
    public TableDataInfo list(RefundApproval refundApproval)
    {
        startPage();
        List<RefundApproval> list = refundApprovalService.selectRefundApprovalList(refundApproval);
        return getDataTable(list);
    }

    /**
     * 导出退款审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:approval:export')")
    @Log(title = "退款审批记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RefundApproval refundApproval)
    {
        List<RefundApproval> list = refundApprovalService.selectRefundApprovalList(refundApproval);
        ExcelUtil<RefundApproval> util = new ExcelUtil<RefundApproval>(RefundApproval.class);
        util.exportExcel(response, list, "退款审批记录数据");
    }

    /**
     * 获取退款审批记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:approval:query')")
    @GetMapping(value = "/{refundApprovalId}")
    public AjaxResult getInfo(@PathVariable("refundApprovalId") Long refundApprovalId)
    {
        return success(refundApprovalService.selectRefundApprovalByRefundApprovalId(refundApprovalId));
    }

    /**
     * 新增退款审批记录
     */
    @PreAuthorize("@ss.hasPermi('business:approval:add')")
    @Log(title = "退款审批记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RefundApproval refundApproval)
    {
        return toAjax(refundApprovalService.insertRefundApproval(refundApproval));
    }

    /**
     * 修改退款审批记录
     */
    @PreAuthorize("@ss.hasPermi('business:approval:edit')")
    @Log(title = "退款审批记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RefundApproval refundApproval)
    {
        return toAjax(refundApprovalService.updateRefundApproval(refundApproval));
    }

    /**
     * 删除退款审批记录
     */
    @PreAuthorize("@ss.hasPermi('business:approval:remove')")
    @Log(title = "退款审批记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refundApprovalIds}")
    public AjaxResult remove(@PathVariable Long[] refundApprovalIds)
    {
        return toAjax(refundApprovalService.deleteRefundApprovalByRefundApprovalIds(refundApprovalIds));
    }
}
